package com.kayt.cyberBar.common.business.job.service.impl;

import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kayt.cyberBar.common.business.job.service.ICyberProductCountJobServer;
import com.kayt.cyberBar.common.business.job.service.ICyberProductCountServer;

@Service("iCyberProductCountServer")
public class CyberProductCountServerImpl implements ICyberProductCountServer {
	private static final Logger logger = LoggerFactory.getLogger(CyberProductCountServerImpl.class);
	
	@Autowired
	private ICyberProductCountJobServer iCyberProductCountJobServer;

	public void execute() throws JobExecutionException {
		logger.info("------- Start CyberProductCountServer --------------");
		long start = System.currentTimeMillis();
		try {
			this.iCyberProductCountJobServer.countTotal();
			this.iCyberProductCountJobServer.copyTotal();
		} catch (Exception e) {
			logger.error("------- Error In CyberProductCountServer --------------", e);
		} finally {
			logger.info(String.format("CyberProductCountServer takes %s milliseconds", new Object[]{Long.valueOf(System.currentTimeMillis() - start)}));
			logger.info(String.format("CyberProductCountServer takes %s minutes", new Object[]{Long.valueOf((System.currentTimeMillis() - start) / 60000L)}));
			logger.info("------- Complete CyberProductCountServer --------------");
		}
	}
}
